#ifndef _FPDF_EMB_ANNOT_H_
#define _FPDF_EMB_ANNOT_H_

#ifdef __cplusplus
extern "C" {
#endif

/********************************************************************************************
****
****		Annotation Information
****
********************************************************************************************/

/**
 * @name Annotation types supported by FPDFEMB
 */
/*@{*/

/** @brief No or unsupported annotation. */
#define FPDFEMB_ANNOT_UNKNOWN				0
/** @brief note annotation. */
#define FPDFEMB_ANNOT_NOTE					0x0001
/** @brief highlight annotation. */
#define FPDFEMB_ANNOT_HIGHLIGHT				0x0002
/** @brief pencil annotation. */
#define FPDFEMB_ANNOT_PENCIL				0x0004
/** @brief stamp annotation. */				
#define FPDFEMB_ANNOT_STAMP					0x0008
/** @brief file attachment annotation. */				
#define	FPDFEMB_ANNOT_FILEATTACHMENT		0x0010

/*@}*/

/**
 * @name Supported information flag for annotation.
 */
/*@{*/

/** @brief type of annotation. */
#define FPDFEMB_ANNOTINFO_TYPE				1
/** @brief author of annotation. */
#define FPDFEMB_ANNOTINFO_AUTHOR			2
/** @brief rectangle of annotation. */
#define FPDFEMB_ANNOTINFO_RECT				3
/** @brief contents of note annotation. */
#define FPDFEMB_ANNOTINFO_CONTENTS			4
/** @brief color of annotation. */
#define FPDFEMB_ANNOTINFO_COLOR				5
/** @brief opacity of annotation. */
#define FPDFEMB_ANNOTINFO_OPACITY			6
/** @brief line width of pencil annotation. */
#define FPDFEMB_ANNOTINFO_LINEWIDTH			7

/*@}*/

/** @brief Data structure for note annotation. */
struct FPDFEMB_ANNOT_NOTEINFO
{
	unsigned int			size;			/**< size of the structure. */
	FPDFEMB_WCHAR			author[64];		/**< author of the annotation. */
	unsigned int			color;			/**< color of the annotation. */
	int						opacity;		/**< opacity of the annotation. */
	int						icon;			/**< reserved. */
	struct FPDFEMB_RECT		rect;			/**< rectangle of the annotation. */
	FPDFEMB_WCHAR*			contents;		/**< contents of the annotation. */
};

/** @brief Data structure for quadrilateral of annotation. */
struct FPDFEMB_ANNOT_QUAD
{	
	/**
	 * @name The text is oriented with respect to the edge connecting points
	 * (x1, y1) and (x2, y2).
	/*@{*/

	int						x1;				/**< x-coordinate of the first vertice */
	int						y1;				/**< y-coordinate of the first vertice */
	int						x2;				/**< x-coordinate of the second vertice */
	int						y2;				/**< y-coordinate of the second vertice */
	int						x3;				/**< x-coordinate of the third vertice */
	int						y3;				/**< y-coordinate of the third vertice */
	int						x4;				/**< x-coordinate of the fourth vertice */
	int						y4;				/**< y-coordinate of the fourth vertice */
	
	/*@}*/
};

/** @brief Data structure for highlight annotation. */
struct FPDFEMB_ANNOT_HIGHLIGHTINFO
{
	unsigned int				size;			/**< size of the structure. */
	FPDFEMB_WCHAR				author[64];		/**< author of the annotation. */
	unsigned int				color;			/**< color of the annotation. */
	int							opacity;		/**< opacity of the annotation, from 0 to 100 */
	int							quad_count;		/**< quadrilateral count of highlight annotation. */
	struct FPDFEMB_ANNOT_QUAD*	quads;			/**< quadrilaterals of highlight annotation. */
};

/** @brief Data structure for line of annotation. */
struct FPDFEMB_ANNOT_LINE
{
	int							point_count;	/**< point count of line in annotation. */
	struct FPDFEMB_POINT*		points;			/**< points of line in annotation. */
};

/** @brief Data structure for pencil annotation. */
struct FPDFEMB_ANNOT_PENCILINFO
{
	unsigned int				size;			/**< size of the structure. */
	FPDFEMB_WCHAR				author[64];		/**< author of the annotation. */
	unsigned int				color;			/**< color of the annotation. */
	int							opacity;		/**< opacity of the annotation. */
	int							busebezier;		/**< whether use bezier curve to connect two points. */
	FPDFEMB_BOOL				boptimize;		/**< whether optimize to decrease points on the line. */
	int							reserved1;		/**< reserved, must be 0. */
	int							line_width;		/**< line width of pencil annotation. */
	int							line_count;		/**< line count of pencil annotation. */
	struct FPDFEMB_ANNOT_LINE*	lines;			/**< lines of pencil annotation. */
};

/** @brief Data structure for Stamp annotation. */
#define FPDFEMB_IMAGETYPE_BMP			1
#define FPDFEMB_IMAGETYPE_JPG			2

struct FPDFEMB_ANNOT_STAMPINFO
{
	unsigned int			size;			/**< size of the structure. */
	FPDFEMB_WCHAR			author[64];		/**< author of the annotation. */
	unsigned int			color;			/**< color of the annotation. */
	int						opacity;		/**< opacity of the annotation. */
	struct FPDFEMB_RECT		rect;			/**< rectangle of the annotation. */
	FPDFEMB_WCHAR			name[32];		/**< subject of the annotation. */
	int						imgtype;		/**< image type of the image data. */
	int						imgdatasize;	/**< image data buffer size. */
	unsigned char*			imgdata;;		/**< image data buffer. */
};

struct FPDFEMB_ANNOT_FILEATTACHMENTINFO
{
	unsigned int			size;			/**< size of the structure. */
	FPDFEMB_WCHAR			author[64];		/**< author of the annotation. */
	unsigned int			color;			/**< color of the annotation. */
	int						opacity;		/**< opacity of the annotation. */
	int						icon;			/**< reserved. 0 */
	struct FPDFEMB_RECT		rect;			/**< rectangle of the annotation. */
	FPDFEMB_WCHAR			filename[256];	/**< file name. */
	int						file_size;		/**< file data buffer size. */
	void*					file_data;		/**< file data buffer. */
};

/**
 * Function: FPDFEMB_Annot_GetCount
 *			Get number of annotations in the page
 *
 * Comments:
 *			This function must be called before any other annotation related function can
 *			be called for the page.
 *
 * @param[in] page			Page handle
 * @param[out] count		Receiving number of annotations
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Annot_GetCount(FPDFEMB_PAGE page, int* count);

/**
 * Function: FPDFEMB_Annot_GetIndexAtPos()
 *			Get index of annotation nearest to a certain position on the page
 *
 * Comments:
 *			This function finds the annotation that's nearest to the particular page position.
 *			If there is no annotation, the output index will be -1.
 *
 * @param[in] page			Page handle
 * @param[in] x				X position in PDF page coordination system, in hundredth of points
 * @param[in] y				Y position in PDF page coordination system, in hundredth of points
 * @param[out] index		Pointer to an integer receiving zero-based annotation index.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_Annot_GetIndexAtPos(FPDFEMB_PAGE page, int x, int y, int* index);

/**
 * Function: FPDFEMB_Annot_GetInfo
 *			Get annotation information
 *
 * Comments:
 *			Application must call FPDFEMB_Annot_GetCount first before it can call this function
 *			for any particular annotation.
 *
 *			If the "buffer" parameter is NULL, then the "bufsize" parameter will receive
 *			number of bytes required to store the annotation information.
 *
 *			If the buffer provided is smaller than the required size, then this function
 *			will not copy any data, return FPDFEMB_PARAM, and the required buffer size will 
 *			also be put in "bufsize" parameter.
 *			
 *			Data type of buffer is depended on the info_type param,
 *			different types are used:\n
 *			FPDFEMB_ANNOTINFO_TYPE:			int
 *			FPDFEMB_ANNOTINFO_AUTHOR:		FPDFEMB_WCHAR
 *			FPDFEMB_ANNOTINFO_RECT:			FPDFEMB_RECT
 *			FPDFEMB_ANNOTINFO_CONTENTS:		FPDFEMB_WCHAR
 *			FPDFEMB_ANNOTINFO_COLOR:		unsigned int
 *			FPDFEMB_ANNOTINFO_OPACITY:		int
 *			FPDFEMB_ANNOTINFO_LINEWIDTH:	int
 *
 *			When data type is FPDFEMB_WCHAR, the output is in Unicode, using UTF-16LE format. 
 *			It's terminated by two consecutive zero bytes.
 *
 * @param[in] page			Page handle
 * @param[in] index			Annotation index, starting from zero
 * @param[in] infotype		The type of the information. See the above FPDFEMB_ANNOTINFO_xxx definitions.
 * @param[out] buffer		A buffer allocated by the application, or NULL.
 * @param[in,out] bufsize	A pointer to a number indicating the buffer size (number of bytes),
 *							before this function call. After return, this place will store
 *							number of bytes used by the output.
 * @return Error code, or FPDFERR_SUCCESS for success
 */
FPDFEMB_RESULT FPDFEMB_Annot_GetInfo(FPDFEMB_PAGE page, int index, int infotype, void* buffer, int* bufsize);

/**
 * Function: FPDFEMB_Annot_SetInfo
 *			Set annotation information
 *
 * @param[in] page			Page handle
 * @param[in] index			Annotation index, starting from zero
 * @param[in] infotype		The type of the information. See the above FPDFEMB_ANNOTINFO_xxx definitions.
 * @param[in] buffer		A buffer allocated by the application, see comments of FPDFEMB_Annot_GetInfo function upon.
 * @param[in] bufsize		the buffer size (number of bytes).
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Annot_SetInfo(FPDFEMB_PAGE page, int index, int infotype, void* buffer, int bufsize);

/**
 * Function: FPDFEMB_Annot_Add
 *			Add a annotation to page
 *
 * 			Data type of data is depended on the annot_type param,
 *			different types are used:\n
 *			FPDFEMB_ANNOT_NOTE:				FPDFEMB_ANNOT_NOTEINFO
 *			FPDFEMB_ANNOT_HIGHLIGHT:		FPDFEMB_ANNOT_HIGHLIGHTINFO
 *			FPDFEMB_ANNOT_PENCIL:			FPDFEMB_ANNOT_PENCILINFO
 *
 * @param[in] page			Page handle
 * @param[in] annottype		Annotation type. See the above FPDFEMB_ANNOT_xxx definitions.
 * @param[in] data			Data struct for annotation, 
 * @param[in] datasize		the data size (number of bytes).
 * @param[out] index		a pointer to receive the added annotation index, starting from zero.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Annot_Add(FPDFEMB_PAGE page, int annottype, void* data, int datasize, int* index);

/**	
 * Function: FPDFEMB_Annot_Delete
 *			Delete a annotation on page
 *
 * @param[in] page			Page handle
 * @param[in] index			Annotation index, starting from zero.
 * @return Error code, or FPDFERR_SUCCESS for success.
 */
FPDFEMB_RESULT FPDFEMB_Annot_Delete(FPDFEMB_PAGE page, int index);

#ifdef __cplusplus
}
#endif

#endif	// #ifndef _FPDF_EMB_ANNOT_H_
